class Intersect
{
	int intersectPoint(Node headA, Node headB)
	{
         // code here
         HashSet<Node> hs=new HashSet<Node>();
         while(headA!=null){
             hs.add(headA);
             headA=headA.next;
         }
         while(headB!=null){
             if(hs.contains(headB)){
                 return headB.data;
             }
             headB=headB.next;
         }
         return -1;
	}
}